home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / PROG_TOO / C027B.ZIP / LIBFP / FPDIV.S < prev    next >
Text File  |  1990-03-30  |  2KB  |  83 lines

  1. * Copyright (c) 1988 by Sozobon, Limited.  Author: Johann Ruegg
  2. *
  3. * Permission is granted to anyone to use this software for any purpose
  4. * on any computer system, and to redistribute it freely, with the
  5. * following restrictions:
  6. * 1) No charge may be made other than reasonable charges for reproduction.
  7. * 2) Modified versions must be clearly marked as such.
  8. * 3) The authors are not responsible for any harmful consequences
  9. *    of using this software, even if they result from defects in it.
  10. *
  11. *
  12. * _fpdiv
  13. *
  14.     .text
  15.     .globl    _fpdiv
  16.     .globl    fpdiv
  17. fpdiv:
  18. _fpdiv:
  19.     link    a6,#-8
  20.     move.l    12(a6),-(sp)
  21.     jsr    _fpinv
  22.     move.l    d0,-4(a6)
  23.     move.l    -4(a6),(sp)
  24.     move.l    12(a6),-(sp)
  25.     jsr    _fpmul
  26.     addq.w    #8,sp
  27.     move.l    d0,-8(a6)
  28.     move.l    -8(a6),-(sp)
  29.     move.l    #$80000042,-(sp)
  30.     jsr    _fpsub
  31.     addq.w    #8,sp
  32.     move.l    d0,-8(a6)
  33.     move.l    -8(a6),-(sp)
  34.     move.l    -4(a6),-(sp)
  35.     move.l    8(a6),-(sp)
  36.     jsr    _fpmul
  37.     addq.w    #8,sp
  38.     move.l    d0,-(sp)
  39.     jsr    _fpmul
  40.     unlk    a6
  41.     rts
  42.     .data
  43. *
  44. * _fpinv
  45. *
  46.     .text
  47.     .globl    _fpinv
  48. _fpinv:
  49.     link    a6,#-4
  50.     move.l    d4,-(sp)
  51.     move.l    8(a6),d4
  52.     move.l    d4,d0
  53.     and.l    #127,d0
  54.     move.w    d0,-2(a6)
  55.     move.l    d4,d0
  56.     and.l    #128,d0
  57.     move.w    d0,-4(a6)
  58.     move.w    #129,d0
  59.     sub.w    -2(a6),d0
  60.     move.w    d0,-2(a6)
  61.     cmp.w    #127,-2(a6)
  62.     ble    L6
  63.     move.w    -4(a6),d0
  64.     or.w    #-129,d0
  65. L5:
  66.     move.l    (sp)+,d4
  67.     unlk    a6
  68.     rts
  69. L6:
  70.     swap    d4
  71.     move.l    #$7fffffff,d0
  72.     divu    d4,d0
  73.     move.l    d0,d4
  74.     swap    d4
  75.     clr.w    d4
  76.     move.w    -4(a6),d0
  77.     ext.l    d0
  78.     or.l    d4,d0
  79.     move.w    -2(a6),d1
  80.     ext.l    d1
  81.     or.l    d1,d0
  82.     bra    L5
  83.